var smallid;
var quid;
var quanid;
var xiaoquid;
var ret;
$(function(){
 smallid= $.query.get("smallid");
 quid=$.query.get("quid");
 quanid=$.query.get("quanid");
 xiaoquid=$.query.get("xiaoquid");

   $.ajax({
        type:"post",
        url:"Ajax.aspx?type=qu",        
        success:function(data){
           if(data!=null&&data.length>0&&data!="0")
           {//alert(data);
                $.CheckedFabu.changed($("#Qu"),data);
                if(quid!=null&&quid!="")//&&quid!="1"
                {                         
                    $.CheckedFabu.selval("#Qu",quid);
                    $.CheckedFabu.showquan("#Qu");
                }
           }
        }//success结束
   });//ajax结束
    
   $("#Qu").change(function(){
    if($(this).val()=="0")
    {
        $("#Quan").html("<option value=\"0\">--商圈--</option>");
        $("#xiaoqu").html("<option value=\"0\">--小区--</option>");
    }
    else
    {   
        $("#qu_hf").val($("#Qu option:selected").text());
        $.ajax({
        type:"post",
        url:"Ajax.aspx?type=quan&quid="+$(this).val(),
        success:function(data){
        if(data!=null&&data.length>0&&data!="0")
          { 
                $("#Quan").html("<option value=\"0\">--商圈--</option>");
                $("#xiaoqu").html("<option value=\"0\">--小区--</option>");
                $.CheckedFabu.changed($("#Quan"),data);
          }
	  else
           {
               $("#Quan").html("<option value=\"0\">--商圈--</option>");
                $("#xiaoqu").html("<option value=\"0\">--小区--</option>");
	   }
        }//success结束
    });//ajax结束
    }    
   });
   $("#Quan").change(function(){
        if($(this).val()=="0")
        {
            $("#xiaoqu").html("<option value=\"0\">--小区--</option>");
        }
        else
        {
           $("#quan_hf").val($("#Quan option:selected").text());
           
           $.ajax({
                type:"post",
                url:"Ajax.aspx?type=xiaoqu&quanid="+$(this).val(),
                success:function(data){
                if(data!=null&&data.length>0&&data!="0")
                  {
                        $("#xiaoqu").html("<option value=\"0\">--小区--</option>");
                        $.CheckedFabu.changed($("#xiaoqu"),data);
                   }
                }//success结束
            });//ajax结束
        }
    });
    $("#xiaoqu").change(function(){
        if($(this).val()=="0")
        {
            
        }
        else
        {
           $("#xiaoqu_hf").val($("#xiaoqu option:selected").text());             
        }
    });
});

$.CheckedFabu = 
{
    changed:function(obj,data)
    {
         var Strshi=data.split(',');
         var info="";
         if(Strshi[0]!=null&&Strshi[0].length>0)
         {
            for(var i=0;i< Strshi.length;i++)
            {
               if(Strshi[i].split('|').length>0)
               {
                   info=Strshi[i].split('|');
                   obj.append("<option value=\""+info[0]+"\">"+info[1]+"</option>");
               }
            }
         }
    },
    selval:function(obj,value)    
    {
        $(obj+" option").each(function(){
            if(this.value == value)
            {
                setTimeout(function() { 
                    $(obj).attr("value",value)
                }, 1000);
                
            }
        });
    },
    showquan:function(obj)
    {
        $.ajax({
        type:"post",
        url:"Ajax.aspx?type=quan&quid="+quid,
        success:function(data){
        if(data!=null&&data.length>0&&data!="0")
          {
                $("#Quan").html("<option value=\"0\">--商圈--</option>");
                $("#xiaoqu").html("<option value=\"0\">--小区--</option>");
                $.CheckedFabu.changed($("#Quan"),data);
                if(quanid!=null&&quanid!=""&&quanid!="0")
                {                         
                    $.CheckedFabu.selval("#Quan",quanid);
                    $.CheckedFabu.showxiaoqu("#xiaoqu");                   
                }
          }
        }//success结束
    });//ajax结束
    },
    showxiaoqu:function(obj){
       $.ajax({
                type:"post",
                url:"Ajax.aspx?type=xiaoqu&quanid="+quanid,
                success:function(data){
                if(data!=null&&data.length>0&&data!="0")
                  {
                        $(obj).html("<option value=\"0\">--小区--</option>");
                        $.CheckedFabu.changed($(obj),data);
                        $.CheckedFabu.selval("#xiaoqu",xiaoquid);
                   }
                }//success结束
            });//ajax结束
    },
    ShowBiaoQian:function(obj)
    {
        if(obj.hide())
        {
            obj.show();
        }
        else
        {
            obj.hide();
        }
    },
    GetBiaoQianByThreeid:function(obj,threeid)
    {
         $.ajax({
                type:"post",
                url:"Ajax.aspx?type=bq&threeid="+threeid,
                success:function(data){
                if(data!=null&&data.length>0&&data!="0")
                  {
                    $("#"+obj).html(data);
                  }
                  else
                  {
                      $("#"+obj).html("");
                  }
                }//success结束
            });//ajax结束
    }
}

//发布页面（吃喝玩乐），类别选择国际旅游
    function show_BQ(obj){
        if(obj.val()=='900')
            {
                 $.CheckedFabu.ShowBiaoQian($("#biaoqian_ddl"));
            }
            else
            {
                 $("#biaoqian_ddl").hide();
            }    
   }
   //针对发布页面用户登录用
$.user_fabu = {
    u_login : function(u_name,u_pwd)
    { 
        //alert(u_name);
        //alert(u_pwd);
         var sda=false;
         $.ajax({
            type:"post",
            url:"Ajax.aspx",
            data:"type=login&u_name="+u_name+"&u_pwd="+u_pwd+"",
            async:false,
            success:function(msg){
            //alert(msg);
            if(msg!=null&&msg.length>0&&msg!="0")
              {
                sda = true;
              }
              else             
               { 
                    sda = false;
               }
            }//success结束
          });//ajax结束
      return sda;
    },
    u_register:function(u_name,u_pwd,u_tel)
    {
         var sda=false;
         $.ajax({
            type:"post",
            url:"Ajax.aspx",
            data:"type=register&u_name="+encodeURIComponent(u_name)+"&u_pwd="+u_pwd+"&u_tel="+u_tel+"",
            async:false,
            success:function(msg){
            if(msg!=null&&msg.length>0&&msg!="0")
              {
                sda = true;                
              }
              else             
              {
                sda = false;
              }
            }//success结束
          });//ajax结束
      return sda;
    },
    u_check_sj:function(a)
    {
        var sda=false;
        $.ajax({
            type:"post",
            url:"Ajax.aspx",
            data:"type=check_sj&u_tel="+a+"",
            async:false,
            success:function(c){
            if(c!=null&&c.length>0&&c!="0")
              {
                sda = false;                
              }
              else             
              {
                sda = true;
              }
            }//success结束
          });//ajax结束
        return sda;
    },
    u_check_name:function(a)
    {
        var sda=false;
        $.ajax({
            type:"post",
            url:"Ajax.aspx",
            data:"type=check_name&u_name="+a+"",
            async:false,
            success:function(c){
            if(c!=null&&c.length>0&&c!="0")
              {
                sda = false;                
              }
              else             
              {
                sda = true;
              }
            }//success结束
          });//ajax结束
        return sda;
    }
}
//获取验证码
        function getyzm(kongjian_name)
        {
            var flg=false
            $.ajax({
            type:"post",
            url:"Ajax.aspx",
            data:"type=reg_tel&phone_num="+ $("#register_shouji_txt").val(),
            async:false,
            success:function(data){
            if(data!=null&&data.length>0&&data!="0")
              {
               if(data==0)
                {
                    //alert("未知错误！");
                   $(kongjian_name).html( "<span class=\"c2\"><span class=\"action_po\"><span class=\"action_po_top\">未知错误</span><span class=\"action_po_bot\"></span></span></span>");
                   $(kongjian_name).removeClass();
                }
                else if(data==3)
                {
                    //alert("该手机号码已经被使用，请更换！");
                    $(kongjian_name).html( "<span class=\"c2\"><span class=\"action_po\"><span class=\"action_po_top\">该手机号码已经被使用，请更换！</span><span class=\"action_po_bot\"></span></span></span>");
                    $(kongjian_name).removeClass();
                }
                else if(data==4)
                {
                    //alert("发送间隔不能少于 180 秒！请稍后再试！");
                    $(kongjian_name).html( "<span class=\"c2\"><span class=\"action_po\"><span class=\"action_po_top\">发送间隔不能少于 180 秒！请稍后再试！</span><span class=\"action_po_bot\"></span></span></span>");
                }
                else if(data.length>2)
                {
                    //alert("验证码已经发送至您的手机！");
                   $("#sj_yzm_hf").val(data);
                   $("#shouji_yzm_txb_Tip").removeClass();
                   $(kongjian_name).addClass("chenggong");                  
                   flg=true;
                }
                else if(data==6)
                {
                    //alert("来路不正确！");
                    $(kongjian_name).html( "<span class=\"c2\"><span class=\"action_po\"><span class=\"action_po_top\">来路不正确</span><span class=\"action_po_bot\"></span></span></span>");
                    $(kongjian_name).removeClass();
                }             
              }
            }//success结束
          });//ajax结束
          
            if(!flg)
            {
                 $("#Button2").removeAttr("disabled","disabled");
            }
            else
            {
                 $("#Button2").attr("disabled","disabled");
            }
            return flg;
        }





       
            function reinitIframes(){
            var iframed = document.getElementById("fabu_iframe_img");
            try{
            var bHeightd = iframed.contentWindow.document.body.scrollHeight;
            var dHeightd = iframed.contentWindow.document.documentElement.scrollHeight;
            var heightd = Math.min(bHeightd, dHeightd);    
            iframed.height =  heightd;
            }catch (ex){}
            }
            window.setInterval("reinitIframes()", 200);
      